<template>
  <view class="my">
    <image class="my-bj" :src="$utils.formatAttachmentUrl(userInfo.bg_url)"></image>
    <view :style="navBarStyle"></view>

    <view class="my-user">

      <view class="basic-flex-horizontal row_1">
        <image class="avatar" :src="$utils.formatAttachmentUrl(userInfo.avatar)"></image>
        <view class="name">{{ userInfo.nickname || '' }}</view>
      </view>

      <view class="row_2">
        <text>{{ userInfo.bio || '' }}</text>
      </view>

      <view class="basic-flex-horizontal row_3">
        <view class="item">
          <image :src="`/static/my/${userInfo.gender === 1 ? 'icon_7nan.png' : 'icon_7nv.png'}`"></image>
        </view>
        <view class="item">广东广州</view>
        <view class="item">中山大学</view>
      </view>

      <view class="basic-flex-sb row_4">

        <view class="basic-flex-horizontal left">
          <view class="basic-flex-center basic-flex-column item" v-for="(item,index) in numList" :key="index">
            <view class="num">{{ userInfo[item.code] || 0 }}</view>
            <view class="text">{{ item.title }}</view>
          </view>
        </view>

        <view class="basic-flex-horizontal right">
          <view class="item">编辑资料</view>
          <view class="item" @click="$utils.jumpPage(`/pages_my/setting`)">
            <image src="/static/my/icon_33sz.png"></image>
          </view>
        </view>

      </view>

      <view class="basic-flex-horizontal row_5">
        <view class="basic-flex-center btn">
          <image class="icon" src="/static/my/icon_27gwc.png"></image>
          <view class="text">购物车</view>
        </view>
        <view class="basic-flex-center btn">
          <image class="icon" src="/static/my/icon_27dd.png"></image>
          <view class="text">订单</view>
        </view>
      </view>

    </view>

    <view class="my-list">
      <view class="basic-flex-horizontal tabs">
        <view class="basic-flex-column basic-flex-center item" v-for="(item,index) in tabs" :key="index"
              @click="selectTab(index)"
              :class="{'this-tab':isTab===index}">
          <view class="title">{{ item.name }}</view>
          <view class="icon"></view>
        </view>
      </view>

      <view class="goods">
        <view class="column">
          <product-item v-for="(item, index) in dataList.filter((val,valIndex)=>valIndex % 2 === 0)" :key="index"
                        :product-data="item"></product-item>
        </view>
        <view class="column">
          <product-item v-for="(item, index) in dataList.filter((val,valIndex)=>valIndex % 2 !== 0)" :key="index"
                        :product-data="item"></product-item>
        </view>
      </view>

    </view>

  </view>
</template>

<script>

import navigationBar from "../../configure/mixins/navigationBar";
import page from "../../configure/mixins/page";

export default {
  mixins: [navigationBar, page],
  props: {
    userInfo: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      numList: [
        {
          title: '关注',
          code: 'follow_me',
        },
        {
          title: '粉丝',
          code: 'follow_you',
        },
        {
          title: '获赞与收藏',
          code: 'num',
        },
        {
          title: '积分',
          code: 'score',
        },
      ],
      tabs: [
        {
          name: '作品',
        },
        {
          name: '收藏',
        },
        {
          name: '赞过',
        },
      ],
      isTab: 0,
    }
  },
  methods: {
    selectTab(index) {
      this.isTab = index
    },
  },
}
</script>

<style lang="scss" scoped>
.my {
  & > .my-bj {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vw;
    z-index: -1;
  }

  & > .my-user {
    padding: 10px 14px 50px;

    & > .row_1 {
      gap: 15px;

      & > .avatar {
        width: 58px;
        height: 58px;
        border-radius: 50%;
      }

      & > .name {
        font-weight: bold;
        font-size: 17px;
        color: #FFFFFF;
      }
    }

    & > .row_2 {
      font-weight: 500;
      font-size: 13px;
      color: #FFFFFF;
      margin: 16px 0px 10px;
    }

    & > .row_3 {
      gap: 8px;

      & > .item {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 19px;
        border: 1px solid rgba(255, 255, 255, 0.52);
        padding: 0px 10px;
        font-weight: 500;
        font-size: 10px;
        color: #FFFFFF;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 20px;

        & > image {
          width: 16px;
          height: 16px;
        }
      }
    }

    & > .row_4 {
      margin: 30px 0px 20px;
      gap: 10px;

      & > .left {
        gap: 20px;

        & > .item {
          gap: 2px;
          color: #FFFFFF;
          font-weight: 500;

          & > .num {
            font-size: 15px;
          }

          & > .text {
            font-size: 11px;
          }
        }
      }

      & > .right {
        gap: 8px;

        & > .item {
          background: rgba(255, 255, 255, 0.2);
          border-radius: 19px;
          border: 1px solid rgba(255, 255, 255, 0.52);
          padding: 0px 10px;
          font-weight: 500;
          font-size: 12px;
          color: #FFFFFF;
          display: flex;
          align-items: center;
          justify-content: center;
          height: 28px;

          & > image {
            width: 16px;
            height: 16px;
          }
        }
      }
    }

    & > .row_5 {
      gap: 13px;

      & > .btn {
        flex: 1;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 6px;
        gap: 8px;
        padding: 12px 0px;

        & > .icon {
          width: 20px;
          height: 20px;
        }

        & > .text {
          font-weight: 500;
          font-size: 14px;
          color: #FFFFFF;
        }
      }
    }

  }

  & > .my-list {
    background: #FFFFFF;
    border-radius: 16px 16px 0px 0px;
    position: relative;
    top: -20px;

    & > .tabs {
      padding: 14px 14px 11px;
      gap: 50px;

      & > .item {
        transition: all 0.3s ease; // 增加过渡效果，平滑过渡
        gap: 3px;

        & > .title {
          font-weight: 500;
          font-size: 15px;
          color: #707070;
        }

        & > .icon {
          width: 0px;
          height: 2px;
          border-radius: 1px;
          background: #FE1C41;
          transition: width 0.3s ease; // 增加宽度变化的过渡
        }
      }

      & > .this-tab {
        & > .title {
          color: #000000;
        }

        & > .icon {
          width: 19px;
        }
      }
    }

    & > .goods {
      padding: 5px;
      display: flex;
      gap: 5px;

      & > .column {
        display: flex;
        flex-direction: column;
        gap: 5px;
        flex: 1;
      }
    }
  }

}
</style>
